package com.cskaoyan.shopping.converter;

import com.cskaoyan.mall.dto.ItemDto;
import com.cskaoyan.mall.dto.ProductDetailDto;
import com.cskaoyan.shopping.dal.entitys.Item;
import com.cskaoyan.mall.dto.ProductDto;
import com.cskaoyan.shopping.dal.entitys.ItemDesc;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

import java.util.List;

@Mapper(componentModel = "spring")
public interface ProductConverter {

    @Mappings({
            @Mapping(source = "id",target = "productId"),
            @Mapping(source = "title",target = "productName"),
            @Mapping(source = "price",target = "salePrice"),
            @Mapping(source = "sell_point",target = "subTitle"),
            @Mapping(source = "imageBig",target = "picUrl")
    })
    ProductDto item2Dto(Item item);

    List<ProductDto> items2Dto(List<Item> items);

    @Mapping(source = "item.id", target = "productId")
    @Mapping(source = "item.price", target = "salePrice")
    @Mapping(source = "item.title", target = "productName")
    @Mapping(source = "item.sell_point", target = "subTitle")
    @Mapping(source = "item.imageBig", target = "productImageBig")
    @Mapping(source = "itemDesc.itemDesc", target = "detail")
    @Mapping(source = "item.images", target = "productImageSmall")
    @Mapping(source = "item.limit_num", target = "limitNum")
    ProductDetailDto toProductDetailDto(Item item, ItemDesc itemDesc);

    ItemDto item2ItemDto(Item item);

    List<ItemDto> items2ItemDtos(List<Item> items);



}
